package main

import "fmt"

type dog struct {
	name string
	age  int
}

type cat struct {
	name  string
	color string
}

// A 是空接口
type A interface {
}

// 因为接口A是空接口 ， 所以函数可以接收任意类型当参数
func test5(a A) {
	fmt.Println(a)
}

// fmt 下的输出接收的参数都是这样的
func test6(a interface{}) {
	fmt.Println(a)
}

func main() {
	var a1 A = dog{"小狗", 2}
	var a2 A = cat{
		name:  "小猫",
		color: "黑色",
	}

	fmt.Println(a1)
	fmt.Println(a2)
	test5(a1)
	test5(a2)

	//map  key string  v  obj
	map1 := make(map[string]interface{})
	map1["name"] = "大黄"
	map1["age"] = 14
	map1["dog"] = dog{name: "小黄", age: 12}

	//切片
	s1 := make([]interface{}, 0, 10)
	s1 = append(s1, a2, a2)
	fmt.Println(s1)

}
